﻿using System;
using System.Collections.Generic;
using System.Text;
using Sinacor.Infra.Core.ProcessManager.Client;
using PSE.ProcessManager.Common.Process;
using PSE.ProcessManager.Common.Gateway;

namespace Sinacor.Process.Bovespa.Financeiro.Client
{
    [Serializable]
    public class Exportacao : SinacorBaseProcessClient
    {
        #region Construtor

        /// <summary>
        /// Construtor padrão
        /// </summary>
        public Exportacao()
        {
            this.Id = ProcessEntity.Catalog.Exportacao.ProcessID;
        }

        #endregion

        #region EventHandler

        public event EventHandler ExportacaoConcluida;

        #endregion

        #region Metodos Públicos

        /// <summary>
        /// Exportar Negocios
        /// </summary>
        /// <param name="processEntity"></param>
        public void ExportarFinanceiro(ProcessEntity.Parameter.FiltroExportacaoFinanceiro entity)
        {
            Message<ProcessEntity.Parameter.FiltroExportacaoFinanceiro> message = new Message<ProcessEntity.Parameter.FiltroExportacaoFinanceiro>();

            message.MessageId = ProcessEntity.Catalog.Exportacao.ExportarFinanceiro.MessageID;
            message.ProcessId = this.Id;
            message.Parameter = entity;
            message.Operation = ProcessEntity.Catalog.Exportacao.ExportarFinanceiro.Operation;
            message.From = "ExportarFinanceiro";

            this.BeginSendMessage(message);
        }

        #endregion

        #region Métodos Override

        /// <summary>
        /// OnMessageReceived
        /// </summary>
        /// <param name="message">BaseMessage</param>
        protected override void OnMessageReceived(BaseMessage message)
        {
            if (message.MessageId == ProcessEntity.Catalog.Exportacao.ExportacaoConcluida.MessageID
                && ExportacaoConcluida != null)
                ExportacaoConcluida(this, new EventArgs());
            else
                base.OnMessageReceived(message);
        }

        #endregion
    }
}
